package gwt.bbsbot.server;

import gwt.bbsbot.server.datastore.DataStoreUtil;
import gwt.bbsbot.server.entity.QuestionDataEntity;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class GetServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		List<QuestionDataEntity> datas = DataStoreUtil.getQuestionData10();
		
		//レスポンス情報を作成する
		resp.setContentType("text/html; charset=\"utf-8\"");

		PrintWriter out = resp.getWriter();
		out.write("<html>");
		out.write("<head><title>AndroindGPS</title></head>");
		out.write("<body>");
		out.write("<h2> select ok </h2>");
		for( QuestionDataEntity entity : datas){
			out.write("<h3>" + entity.getName() + " " + entity.getQuestionData() + "</h3>");
		}
		out.write("</body>");
		out.write("</html>");	
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doGet(req, resp);
	}
}
